# Maintainer: Ryuta Suzuki <oroppas@gmail.com>

_realname=xlsxwriter
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.3.7
pkgrel=1
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}=${pkgver}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgdesc="A Python module for creating Excel XLSL files (mingw-w64)"
url="https://github.com/jmcnamara/XlsxWriter"
arch=('any')
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/jmcnamara/XlsxWriter/archive/RELEASE_${pkgver}.tar.gz")
sha256sums=('b08a1b30cde383cf3b09b50fa18fbfca28ec977e5df9ffab89f01a2ca93be2c1')

build() {
  cd "${srcdir}/XlsxWriter-RELEASE_${pkgver}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/XlsxWriter-RELEASE_${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE

  local _mingw_prefix=$(cygpath -am ${MINGW_PREFIX})
  for filename in vba_extract; do
    sed -e "s|${_mingw_prefix}/bin/|/usr/bin/env |g" -i "${pkgdir}${MINGW_PREFIX}"/bin/${filename}.py
  done
}
